<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>
        //JSON转换为JS对象 JSON.parse(JSON)
        var jsonStr = '{"a": "hello", "b": "world"}';
        var obj = JSON.parse(jsonStr);
        console.log(obj);


        //JS对象转换为JSON JSON.stringify(js)
        var obj2 = {
            a: "hello",
            b: "world"
        }
        var json2 = JSON.stringify(obj2);
        console.log(json2);

    </script>
</body>

</html>